﻿using System.Web.Mvc;
using DevTrends.MvcDonutCaching;
using KMF.Utility;
using KMF.WebUI.CustomHelpers;
using KMF.WebUI.Infrastructure;

namespace KMF.WebUI.Controllers
{
    public class CacheController : Controller
    {
        [HttpGet]
        public JsonpResult DeleteCache(string userName = "", string pass = "")
        {
            if(userName.Equals("tuananh") && pass.Equals("0320853356"))
            {
                Session[SessionConfig.SessionWebInfo] = null; 
                var cacheManager = new OutputCacheManager();
                try
                {
                    cacheManager.RemoveItems();
                    CacheLayer.ClearAll();
                    ConfigInfo.LoadData();
                }
                catch
                {
                    return new JsonpResult("Xóa cache thất bại!");
                }
                return new JsonpResult("Xóa cache thành công");
            }
            return new JsonpResult("Xóa cache thất bại");
        }
    }
}
